package Unit

import (
	. "GameLogic/GameConfig"
	. "GameLogic/Scene"
	xml "misc/dom4g"
)

type IEffect interface {
	Exec()
	GetBaseInfo() *EffectInfo
}

type EffectInfo struct {
	Name    string
	Type    string
	SrcUnit IUnit
	DstUnit IUnit
}

func (this *EffectInfo) Parse(node *xml.Element) {
	this.Name, _ = node.AttrValue("Name")
	this.Type = node.Name()
}

type EffectCreateFunc func(*xml.Element) IEffect

var EffectCreateFuncMap map[string]EffectCreateFunc

func CreateEffect(effectName string) IEffect {
	xmlNode := GetXmlEffect(effectName)
	CreateFn := EffectCreateFuncMap[xmlNode.Name()]
	return CreateFn(xmlNode)
}
